package com.macro.mall.portal.service.impl;

import com.github.pagehelper.PageHelper;
import com.macro.mall.mapper.BmsGuidePointMapper;
import com.macro.mall.mapper.BmsGuidePointPicMapper;
import com.macro.mall.model.BmsGuidePoint;
import com.macro.mall.model.BmsGuidePointPic;
import com.macro.mall.portal.dto.BmsGuidePointDetail;
import com.macro.mall.portal.dto.BmsGuidePointParam;
import com.macro.mall.portal.service.BmsGuidePointService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


/**
 * 观光车点位图片Service实现类
 * Created by macro on 2018/4/26.
 */
@Service
public class BmsGuidePointServiceImpl implements BmsGuidePointService {

    @Autowired
    private BmsGuidePointMapper bmsGuidePointMapper;
    @Autowired
    private BmsGuidePointPicMapper bmsGuidePointPicMapper;

    /**
     * 获取列表
     * @param bmsGuidePointParam
     * @return
     */
    @Override
    public List<BmsGuidePoint> getList(BmsGuidePointParam bmsGuidePointParam) {
        BmsGuidePoint bmsGuidePoint = new BmsGuidePoint();
        BeanUtils.copyProperties(bmsGuidePointParam, bmsGuidePoint);
        List<BmsGuidePoint> list = bmsGuidePointMapper.getListNew(bmsGuidePoint);
        return list;
    }

    @Override
    public BmsGuidePoint getDetail(Long id) {
        BmsGuidePoint bmsGuidePoint = bmsGuidePointMapper.selectDetail(id);
        BmsGuidePointDetail detail = new BmsGuidePointDetail();
        if (bmsGuidePoint != null) {
            BeanUtils.copyProperties(bmsGuidePoint, detail);
            // 获取封面图
            String coverPic = bmsGuidePointMapper.findCoverPicByActivitiesId(id);
            // 获取活动图片
            List<String> picList = bmsGuidePointMapper.findPicListByActivitiesId(id);
            detail.setCoverPic(coverPic);
            detail.setPicList(picList);
        }
        return detail;
    }


}
